﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;

public class ItemGameRecommend
{

    static Color[] _NameColors = new Color[] { CretorRgb(255, 228, 223), CretorRgb(255, 182, 169) };
    static Color[] _DescColors = new Color[] { CretorRgb(230, 164, 152), CretorRgb(242, 173, 160) };
    private Image _ImgName;//255 228 223    255 182 169
    private Image _ImgDesc;//230 164 152   242 173 160    
    private Text _TxtName;
    private Text _TxtDesc;
    private RecommendData _Data;
    private GameObject gameobject;
    private Transform transform;
    public void Init(GameObject go, RecommendData data)
    {
        gameobject = go;
        transform = gameobject.transform;
        _Data = data;

        _ImgName = transform.Find("ImgName").GetComponent<Image>();
        _ImgDesc = transform.Find("ImgDesc").GetComponent<Image>();
        _TxtName = _ImgName.transform.Find("TxtName").GetComponent<Text>();
        _TxtDesc = _ImgDesc.transform.Find("TxtDesc").GetComponent<Text>();
        InitUI();
    }

    private void InitUI()
    {
        _TxtName.text = _Data.GameName;
        _TxtDesc.text = _Data.GameDesc;
        int index = _Data.Index % 2;
        _ImgName.color = _NameColors[index];
        _ImgDesc.color = _DescColors[index];
    }
    

    public static Color CretorRgb(int r, int g, int b)
    {
        return new Color(r / 255.00f, g / 255.00f, b / 255.00f);
    }
}

